//
//  WBStatusCell.swift
//  weibo
//
//  Created by wenquan wang on 12/22/16.
//  Copyright © 2016 wenquan wang. All rights reserved.
//

import UIKit

class WBStatusCell: UITableViewCell {

    var viewModel: WBStatusViewModel? {
        didSet{
            statusLabel.text = viewModel?.status.text
            nameLabel.text = viewModel?.status.user?.screen_name
            memberIconView.image = viewModel?.memberIcon
            vipIconView.image = viewModel?.vipIcon
            iconView.cz_setImage(urlString: viewModel?.status.user?.profile_image_url, placeholderImage: UIImage(named: "avatar_default_big"), isAvatar: true)
            toolBar.viewModel = viewModel
            //pictureView.heightCons.constant = viewModel?.pictureViewSize.height ?? 0
            pictureView.viewModel = viewModel
            
            /** test 4 pics
            if viewModel?.status.pic_urls?.count ?? 0 > 4{
                var picUrls = viewModel!.status.pic_urls!
                picUrls.removeSubrange((picUrls.startIndex + 4)..<picUrls.endIndex)
                pictureView.urls = picUrls
            }
            else{
                pictureView.urls = viewModel?.status.pic_urls
            }
            */
            //pictureView.urls = viewModel?.picURLs
            
            retweetedLabel?.text = viewModel?.retweetedText
        }
    }
    
    @IBOutlet weak var iconView: UIImageView!
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var memberIconView: UIImageView!
    @IBOutlet weak var timeLabel: UILabel!
    //from
    @IBOutlet weak var sourceLabel: UILabel!
    //cert vip
    @IBOutlet weak var vipIconView: UIImageView!
    //content
    @IBOutlet weak var statusLabel: UILabel!
    
    
    @IBOutlet weak var toolBar: WBStatusToolBar!
    
    @IBOutlet weak var pictureView: WBStatusPictureView!
    
    @IBOutlet weak var retweetedLabel: UILabel?
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        self.layer.drawsAsynchronously = true
        
        self.layer.shouldRasterize = true
        
        self.layer.rasterizationScale = UIScreen.main.scale
    }

}
